package mgt

import gateway.mgt.*

class BootStrap {

    def init = { servletContext ->
        def role_user = new Role(authority: "ROLE_USER").save()
        def role_admin = new Role(authority: "ROLE_ADMIN").save()

        def roleGroupUser = new RoleGroup(name: "RG_USER").save()
        def roleGroupAdmin = new RoleGroup(name: "RG_ADMIN").save()

        RoleGroupRole.create(roleGroupUser, role_user)
        RoleGroupRole.create(roleGroupAdmin, role_user)
        RoleGroupRole.create(roleGroupAdmin, role_admin)

        def user = new User(username: "user", password: "123").save()
        def admin = new User(username: "admin", password: "adminadmin").save()

        UserRoleGroup.create(user, roleGroupUser)
        UserRoleGroup.create(admin, roleGroupAdmin)
    }
    def destroy = {
    }
}
